from datetime import timedelta

import pandas as pd
import os
import numpy as np

repo_name_list = [ "rails"]
all_alg_list = [
    "original"
]
for repo_name in repo_name_list:

    data_file_name = "/Users/jiajunyu/PycharmProjects/pr_2023/Supplementary Materials/Process Simulation/Results/" + repo_name + "/Results/" + repo_name + "_annual_averages.csv"
    # 读取csv文件
    data = pd.read_csv(data_file_name)

    # 将DataFrame写入xlsx文件
    data.to_excel("/Users/jiajunyu/PycharmProjects/pr_2023/Supplementary Materials/Process Simulation/Results/" + repo_name + "/Results/original.xlsx", index=False)

import os

# repo_name_list = ["cmssw", "django", "kubernetes", "moby", "opencv", "pandas", "rails", "react", "rust",
#                   "salt", "scikit-learn", "symfony", "tensorflow", "terraform", "yii2"]
# all_alg_list = [
#     "original"
# ]
# for repo_name in repo_name_list:
#     # 指定需要修改的目录路径
#     directory = "/Users/jiajunyu/PycharmProjects/pr_2023/Supplementary Materials/Process Simulation/Results/"+repo_name+"/Results/"
#
#     # 遍历目录下的所有文件
#     for filename in os.listdir(directory):
#         # 检查文件名是否符合xxx_result.xlsx格式
#         if filename.endswith('_result.xlsx'):
#             # 提取'xxx'部分作为新文件名
#             new_filename = filename.replace('_result.xlsx', '.xlsx')
#
#             # 获取旧文件完整路径
#             old_file_path = os.path.join(directory, filename)
#
#             # 计算新文件的完整路径
#             new_file_path = os.path.join(directory, new_filename)
#
#             # 重命名文件
#             os.rename(old_file_path, new_file_path)
#
#     print("文件重命名完成")
# repo_name_list = ["cmssw"]
# repo_name_list = ["cmssw", "django", "kubernetes", "moby", "opencv", "pandas", "rails", "react", "rust",
#                   "salt", "scikit-learn", "symfony", "tensorflow", "terraform", "yii2"]
#
# for repo_name in repo_name_list:
#     # 指定需要修改的目录路径
#     directory = "/Users/jiajunyu/PycharmProjects/pr_2023/Supplementary Materials/Process Simulation/Results/" + repo_name + "/Results/"
#     all_alg_list = [
#         "MART",
#         "RankBoost",
#         "AdaRank",
#         "Coordinate",
#         "LambdaMART",
#         "ListNet",
#         "FIFO",
#         "SSF"
#     ]
#
#     for alg_name in all_alg_list:
#         # 读取xlsx文件内容到DataFrame
#         df = pd.read_excel(directory+alg_name + '.xlsx')
#
#         # 删除最后一行
#         df = df[:-1]
#
#         df.to_excel(directory+alg_name + '.xlsx', index=False)
#
#     print("文件重命名完成")
